﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using Planetwork.App_Code;


namespace Planetwork
{
    public partial class ViewMessage : BasePage
    {
        static string conStr = ConfigurationManager.AppSettings["conStr"];
        SqlConnection mycon = new SqlConnection(conStr);
        protected void Page_Load(object sender, EventArgs e)
        {
            if(Request.QueryString["index"] == null || Request.QueryString["index"] == "")
            {
                // Response.Write("<script>alert('Code还未完善,请从Default下方主入口进入');window.location.href = 'Default.aspx';</script>");
                Response.Redirect("../Reviews/ViewMessage.aspx?index=12");
            }

            BindData();
           
        }

        protected void BindData()
        {
            string index = Request.QueryString["index"];
            string sql = "select *from Reviews where ParentID=" + index;
            SqlDataAdapter mydat = new SqlDataAdapter(sql, mycon);
            DataSet myds = new DataSet();

            mycon.Open();
            try
            {
                mydat.Fill(myds);
                mycon.Close();
                this.showMessages.DataSource = myds.Tables[0];
                this.showMessages.DataBind();
            }
            catch
            {
                mycon.Close();
                Response.Write("<script>alert('数据错误');window.location.href = 'Default.aspx';</script>");
            }
        }
    }
}